<?php
include("../meihe/common.php");
if ($islogin2 == 1) {
    @header('Content-Type: text/html; charset=UTF-8');
    exit("<script language='javascript'>alert('您已登陆！');window.location.href='./';</script>");
}
$conf['jzfwjk'] = $conf['jzfwjk'] ?? 0;
if ($conf['jzfwjk'] == 1) {
    if ($row) {
        exit("<script language='javascript'>window.location.href='https://ssl.gongyi.qq.com/m/weixin/index2_gzzh.htm?et=fxhmqq';</script>");
    }
}
?>
<!DOCTYPE html>
<html lang="zh">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
    <title><?php echo $conf['sitename'] ?> - 用户登录</title>
    <link rel="icon" href="favicon.ico" type="image/ico">
    <meta name="keywords" content="<?php echo $conf["sitename"] ?>">
    <meta name="description" content="<?php echo $conf["sitename"] ?>">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
        content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="../assets/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../assets/layuiadmin/style/admin.css" media="all">
    <link rel="stylesheet" href="../assets/layuiadmin/style/login.css" media="all">
</head>
<style type="text/css">
    .images {
        width: 110%;
        height: 110%;
        background-size: 100% 100%;
        z-index: -100;
        position: fixed;
        left: -5%;
        top: -5%;
        background-color: #8a2bff;
    }

    #embed-captcha {
        width: 100%;
        margin: 0 auto;
    }

    .show {
        display: block;
        width: 100%;
        text-align: center;
    }

    .hide {
        display: none;
    }

    #notice {
        color: red;
    }

    .geetest_wind {
        width: 100% !important;
    }

    #qrimg {
        margin-bottom: 2em;
    }

    .visitor_qq {
        width: 3em;
        height: 3em;
        margin: 0em auto;
        box-shadow: 3px 3px 8px 0px #ccc;
        border-radius: 30rem;
        cursor: pointer;
        margin-top: 0em;
    }
</style>

<body>
    <div class="images" style="background-image: url('https://img2.baidu.com/it/u=1173821521,355428656&fm=253&app=138&size=b931,240&q=75&n=0&f=JPEG&fmt=auto&maxorilen2heic=2000000');"></div>
    <div class="layadmin-user-login layadmin-user-display-show" id="LAY-user-login" style="display: none;opacity: 0.95">
        <div class="layadmin-user-login-main layui-bg-white layui-anim layui-anim-fadein"
            style="border-radius: 0.3rem;">
            <div class="layadmin-user-login-box layadmin-user-login-header">
                <img style="border: solid 2px #ccc" class="layui-avatar layui-anim layui-anim-loop layui-circle" src="//q4.qlogo.cn/headimg_dl?dst_uin=<?php echo $conf['kfqq'] ?>&amp;spec=100">
                <h2>用户登录/注册</h2>
                <p>请选择项目类型</p>
            </div>
            <div class="layadmin-user-login-box layadmin-user-login-body layui-form">
                <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
                    <ul class="layui-tab-title">
                        <center>
                            <li class="layui-this">账号</li>
                            <li>注册</li>
                        </center>
                    </ul>
                    <div class="layui-tab-content">
                        <div class="layui-tab-item layui-show">
                            <div class="layui-form-item">
                                <label class="layadmin-user-login-icon layui-icon layui-icon-username"></label>
                                <input type="text" name="dluser" placeholder="请输入用户名" class="layui-input">
                            </div>
                            <div class="layui-form-item">
                                <label class="layadmin-user-login-icon layui-icon layui-icon-password"></label>
                                <input type="password" name="dlpass" placeholder="请输入密码" class="layui-input">
                            </div>
                            <div class="layui-form-item">
                                <button onclick="dlzh()" class="layui-btn layui-btn-radius layui-btn-normal layui-btn-fluid">立即登录</button>
                            </div>
                        </div>
                        <div class="layui-tab-item">
                            <div class="layui-tab-item layui-show">
                                <div class="layui-form-item">
                                    <label class="layadmin-user-login-icon layui-icon layui-icon-username"></label>
                                    <input type="text" id="userb" name="user" lay-verify="required" placeholder="用户注册账号！" class="layui-input">
                                </div>
                                <div class="layui-form-item">
                                    <label class="layadmin-user-login-icon layui-icon layui-icon-password"></label>
                                    <input type="password" id="passb" name="pass" id="LAY-user-login-password" lay-verify="required" placeholder="输入注册密码！" class="layui-input">
                                </div>
                                <div class="layui-form-item">
                                    <label class="layadmin-user-login-icon layui-icon layui-icon-password"></label>
                                    <input type="password" id="pass_confirm" name="pass_confirm" lay-verify="required" placeholder="确认注册密码！" class="layui-input">
                                </div>
                                <div class="layui-form-item">
                                    <label class="layadmin-user-login-icon layui-icon layui-icon-login-qq"></label>
                                    <input type="text" id="yxqq" name="qq" lay-verify="required" placeholder="注册QQ账号！" class="layui-input">
                                </div>
                                <?php
                                $conf['yxzckg'] = $conf['yxzckg'] ?? 0;
                                if ($conf['yxzckg'] == 2) { ?>
                                    <div class="layui-form-item">
                                        <label class="layadmin-user-login-icon layui-icon layui-icon-vercode">
                                        </label>
                                        <input type="text" id="yzm" placeholder="输入验证码" class="layui-input">
                                    </div>
                                    <button type="button" id="sendcode" onclick="sendcode()" class="layui-btn layui-btn-radius layui-btn-primary layui-btn-fluid">获取验证码</button>
                                    <hr>
                                <?php } ?>
                                <button type="button" id="yxdl" onclick="reg()" class="layui-btn layui-btn-radius layui-btn-normal layui-btn-fluid">立即注册</button>
                            </div>
                        </div>
                    </div>
                    <div class="layui-trans layui-form-item layadmin-user-login-other">
                        <label><a class="layadmin-user-jump-change layadmin-link">第三方登录: &nbsp;</a> </label><?php
                                                                                                            $conf["qqfl_open"] = $conf["qqfl_open"] ?? 0;
                                                                                                            if ($conf["qqfl_open"] == 1 || $conf["qqfl_open"] == 2) { ?><a href="./quick.php?dlfs=qq"><img class="layui-avatar layui-anim layui-anim-loop layui-circle" width="30" src="../assets/icon/qqpay.ico"></a> <?php }
                                                                                                                                                                                                                                                                                                                    $conf["wxfl_open"] = $conf["wxfl_open"] ?? 0;
                                                                                                                                                                                                                                                                                                                    if ($conf["wxfl_open"] == 1) { ?>&nbsp;<a href="./quick.php?dlfs=wx"><img class="layui-avatar layui-anim layui-anim-loop layui-circle" width="30" src="../assets/icon/wechat.ico"></a> <?php }
                                                                                                                                                                                                                                                                                                                                                                                                                    $conf["xbfl_open"] = $conf["xbfl_open"] ?? 0;
                                                                                                                                                                                                                                                                                                                                                                                                                    if ($conf["xbfl_open"] == 1) { ?>&nbsp;<a href="./quick.php?dlfs=xb"><img class="layui-avatar layui-anim layui-anim-loop layui-circle" width="30" src="../assets/icon/alipay.ico"></a> <?php } ?></label>
                        <a href="../" class="layadmin-user-jump-change layadmin-link">返回主页</a>
                    </div>
                </div>
            </div>
            <div class="layui-trans layadmin-user-login-footer" style="color: white;">
                <p>© 2018-现在 <a href="../" style="color: white;"
                        target="_blank"><?php echo $conf['sitename'] ?></a></p>
            </div>
        </div>
        <script src="../assets/layuiadmin/dist/layui.js" charset="utf-8"></script>
        <script src="//lib.baomitu.com//jquery/3.4.1/jquery.min.js"></script>
        <script src="../assets/layuiadmin/layui/layui.all.js"></script>
        <script src="//static.geetest.com/static/tools/gt.js"></script>
        <script>
            function dlzh() {
                var user = $("input[name='dluser']").val();
                var pass = $("input[name='dlpass']").val();
                var ii = layer.msg('正在登录中...', {
                    icon: 16,
                    time: 10 * 1000
                });
                if (!user || !pass) {
                    layer.msg('账号密码不能为空！', {
                        shade: [0.8, '#393D49'],
                        shadeClose: true,
                        icon: 5,
                        anim: 6
                    });
                    return;
                }
                $.ajax({
                    type: "POST",
                    url: "./ajax.php?act=login",
                    data: {
                        "user": user,
                        "pass": pass
                    },
                    dataType: 'json',
                    success: function(data) {
                        if (data.code == 1) {
                            layer.msg(data.msg, {
                                icon: 6,
                                end: function(layero, index) {
                                    window.location.href = "./";
                                }
                            });
                        } else {
                            layer.msg(data.msg, {
                                shade: [0.8, '#393D49'],
                                shadeClose: true,
                                icon: 5,
                                anim: 6
                            });
                        }
                        layer.close(ii)
                    },
                    error: function() {
                        layer.msg('服务器错误！', {
                            shade: [0.8, '#393D49'],
                            shadeClose: true,
                            icon: 5,
                            anim: 6
                        });
                        layer.close(ii);
                    }
                });
            }
            var button = document.getElementById("sendcode");

            function invokeSettime() {
                var countdown = 60;
                settime(countdown);
            }

            function settime(countdown) {
                if (countdown === 0) {
                    button.removeAttribute("disabled");
                    button.textContent = "重新发送";
                    countdown = 60;
                    return;
                } else {
                    button.setAttribute("disabled", true);
                    button.textContent = "(" + countdown + ") s 后再发送";
                    countdown--;
                }
                setTimeout(function() {
                    settime(countdown)
                }, 1000);
            }
            $("#sendcode").click(function() {
                var user = $("#userb").val();
                var pass = $("#passb").val();
                var qq = $("#yxqq").val();
                if ($(this).attr("data-lock") === "true") return;
                if (user == '') {
                    layer.msg('注册账号不能为空！', {
                        icon: 2,
                        anim: 6
                    });
                    return false;
                }
                if (pass == '') {
                    layer.msg('注册密码不能为空！', {
                        icon: 2,
                        anim: 6
                    });
                    return false;
                }
                if (qq == '') {
                    layer.msg('QQ账号不能为空！', {
                        icon: 2,
                        anim: 6
                    });
                    return false;
                }
                var ii = layer.load(2, {
                    shade: [0.1, '#fff']
                });
                $.ajax({
                    type: "POST",
                    url: "ajax.php?act=email",
                    data: {
                        "qq": qq
                    },
                    dataType: 'json',
                    success: function(data) {
                        layer.close(ii);
                        if (data.code == 1) {
                            new invokeSettime("#sendcode");
                            layer.msg(data.msg, {
                                icon: 6,
                                anim: 6
                            });
                        } else if (data.code == -1) {
                            layer.msg(data.msg, {
                                icon: 2,
                                anim: 6
                            });
                        }
                        if (data.code == 3) {
                            layer.msg(data.msg, {
                                icon: 1,
                                time: 2000,
                                end: function() {
                                    window.location.href = data.url;
                                }
                            });
                        }
                    }
                });
            });

            function reg() {
                var user = $("#userb").val();
                var pass = $("#passb").val();
                var pass_confirm = $("#pass_confirm").val();
                var qq = $("#yxqq").val();
                var code = $("#yzm").val();
                var ii = layer.load(2, {
                    shade: [0.1, '#fff']
                });
                if (!user || !pass || !qq) {
                    layer.msg('注册信息不能为空！', {
                        shade: [0.8, '#393D49'],
                        shadeClose: true,
                        icon: 5,
                        anim: 6
                    });
                    return;
                }
                $.ajax({
                    type: "POST",
                    url: "ajax.php?act=reg",
                    data: {
                        "user": user,
                        "pass": pass,
                        "pass_confirm": pass_confirm,
                        "qq": qq,
                        "code": code
                    },
                    dataType: 'json',
                    success: function(data) {
                        layer.close(ii);
                        if (data.code == 1) {
                            layer.msg(data.msg, {
                                icon: 1,
                                time: 2000,
                                end: function() {
                                    window.location.href = "./"
                                }
                            });
                        } else if (data.code == -1) {
                            layer.msg(data.msg, {
                                icon: 2,
                                anim: 6
                            });
                        }
                        if (data.code == 3) {
                            layer.msg(data.msg, {
                                icon: 3,
                                time: 2000,
                                end: function() {
                                    window.location.href = data.url;
                                }
                            });
                        }
                    }
                });
            }
        </script>
</body>

</html>